<%@ include file="/common/taglibs.jsp"%>
<script type="text/javascript"
	src="<c:url value='/js/jquery/jquery.numeric.js'/>"></script>
<script type="text/javascript"
	src="<c:url value='/js/jquery/jquery.formatCurrency-1.4.0.pack.js'/>"></script>
<link href="<c:url value='/css/dhtmlxcombo_paylineitem.css' />"
	rel="stylesheet" type="text/css" />
	
<script type="text/javascript">

	$(document).ready(function() {		
		<c:choose>
			<c:when test="${cipeproject.id !=null and cipeproject.id gt 0}">
				$('#pageTitle').text('<spring:message code="editCipeproject.heading.view" />');
			</c:when>
			<c:otherwise>
				$('#pageTitle').text('<spring:message code="editCipeproject.heading" />');
			</c:otherwise>
		</c:choose>	

		textboxes = $("input:text");
		selects = $('#editCipeprojectForm select');
		
	   if ($.browser.mozilla) {
	      $(textboxes).keypress(checkForEnter);
	      $(selects).keypress(checkForEnter);
	   } else {
	      $(textboxes).keydown(checkForEnter);
	      $(selects).keypress(checkForEnter);
	   }

	   function checkForEnter(event) {
	      if (event.keyCode == 13) {
	         var currentTabNumber = $(this).attr("tabindex");
	         if(currentTabNumber!=null){
	        		//alert($(this).attr("tabindex"));
					var inputs = $('#editCipeprojectForm :input');
					var selects = $('#editCipeprojectForm select');
					var checkboxes = $('#editCipeprojectForm checkbox');

					selects.each(function() {
						if($(this).attr("tabindex")==currentTabNumber+1){
							$(this).focus();
							}
					});
					
					inputs.each(function() {
						if($(this).attr("tabindex")==currentTabNumber+1){
							$(this).focus();
							}
					});
					
					checkboxes.each(function() {
						if($(this).attr("tabindex")==currentTabNumber+1){
							//alert("ab");
							$(this).focus();
							}
					});
		         }
	      
	         /*currentTextboxNumber = textboxes.index(this);
	         if (textboxes[currentTextboxNumber + 1] != null) {
	           nextTextbox = textboxes[currentTextboxNumber + 1];
	           nextTextbox.select();
	      }*/

	         event.preventDefault();
	         return false;
	      }
	   }
	   <c:if test="${cipeproject.id ==null || cipeproject.id == 0}">

		var pickerOpts = {
				onClose : function() {
					this.focus();
				}
			};
	
			
			$("#projectStartDate").datepicker(pickerOpts);        
		
			
			$("#projectEndDate").datepicker(pickerOpts);
			
			$("#overridePeriodStartDate").datepicker(pickerOpts);        
		
			
			$("#overridePeriodEndDate").datepicker(pickerOpts);
			
			
	   </c:if>
		
		$.validator.addMethod("partner_drop_down_required", function(value, element) {
			var projecttype = z1.getSelectedText();
			if(projecttype=="Management"/*value=30*/ || projecttype=="Partner"/*value=32*/) {
				return (value != "");
			}
			return true;
		}, "Please select an option.");

		$.validator.addMethod("endDateValidation", function(value, element) {
			var date_ini = new Date($('#projectStartDate').val()).getTime();
			var date_end = new Date($('#projectEndDate').val()).getTime();
			if (isNaN(date_ini)) {
				//if required we will add code
			} else if (isNaN(date_end)) {
				//if required we will add code
			} else if (date_ini > date_end) {
				return false;

			}
			return true;
		},  "Project End Date must be greater than the Project Start Date."
		);

		$.validator.addMethod("startDateValidation", function(value, element) {
			var date_ini = new Date($('#projectStartDate').val()).getTime();
			var date_end = new Date($('#projectEndDate').val()).getTime();
			if (isNaN(date_ini)) {
			} else if (isNaN(date_end)) {
			} else if (date_ini > date_end) {
				return false;

			}
			return true;
		},  "Project Start Date must be less than the Project End Date."
		);
		
		$.validator.addMethod("startDateValidateDonorAward",function(value,element){
		  	var date_ini = new Date($('#projectStartDate').val()).getTime();
			var date_end = new Date($('#donorStartDate').val()).getTime();
			if (isNaN(date_ini)) {
			} else if (isNaN(date_end)) {
			} else if (date_ini < date_end) {
				return false;
			}
			return true;
		 },
		  "Project Start Date must be greater than or equal to the Donor Award Start Date."
		 );
		
		$.validator.addMethod("endDateValidateDonorAward",function(value,element){
		  	var date_ini = new Date($('#projectEndDate').val()).getTime();
			var date_end = new Date($('#donorEndDate').val()).getTime();
			if (isNaN(date_ini)) {
			} else if (isNaN(date_end)) {
			} else if (date_ini > date_end) {
				return false;
			}
			return true;
		 },
		  "Project End Date must be less than or equal to Donor Award End Date."
		 );

		$.validator.addMethod("startDateDonorEndDateValidateDonorAward",function(value,element){
		  	var date_ini = new Date($('#projectStartDate').val()).getTime();
			var date_end = new Date($('#donorEndDate').val()).getTime();
			if (isNaN(date_ini)) {
			} else if (isNaN(date_end)) {
			} else if (date_ini > date_end) {
				return false;
			}
			return true;
		 },
		  "Project Start Date must be less than or equal to the Donor Award End Date."
		 );

		$.validator.addMethod("endDateDonorStartDateValidateDonorAward",function(value,element){
		  	var date_ini = new Date($('#projectEndDate').val()).getTime();
			var date_end = new Date($('#donorStartDate').val()).getTime();
			if (isNaN(date_ini)) {
			} else if (isNaN(date_end)) {
			} else if (date_ini < date_end) {
				return false;
			}
			return true;
		 },
		  "Project End Date must be greater than or equal to the Donor Award Start Date."
		 );

			$.validator.addMethod("overrideValidation", function(value, element) {
				if ($('input[name="override"]').prop('checked') && ($("#overrideAmount").val() == "" || $("#overridePeriodStartDate").val() == "" || $("#overridePeriodEndDate").val() == "")) {
					return false;
				}
				return true;
			},  "You must enter Budget Override Amount, Budget Override Period Start and End Dates."
			);

			$.validator.addMethod("overridePeriodEndDateValidation", function(value, element) {
				var date_ini = new Date($('#overridePeriodStartDate').val()).getTime();
				var date_end = new Date($('#overridePeriodEndDate').val()).getTime();
				if (isNaN(date_ini)) {
					//if required we will add code
				} else if (isNaN(date_end)) {
					//if required we will add code
				} else if (date_ini > date_end) {
					return false;

				}
				return true;
			},  "Budget Override Period End Date must be greater than the Budget Override Period Start Date."
			);

			$.validator.addMethod("overridePeriodStartDateValidation", function(value, element) {
				var date_ini = new Date($('#overridePeriodStartDate').val()).getTime();
				var date_end = new Date($('#overridePeriodEndDate').val()).getTime();
				if (isNaN(date_ini)) {
				} else if (isNaN(date_end)) {
				} else if (date_ini > date_end) {
					return false;

				}
				return true;
			},  "Budget Override Period Start Date must be less than the Budget Override Period End Date."
			);
		 
		$.validator.addMethod("validateCostCenterNumber",function(value,element){
		  	var ccval = $('#costCenterNumber').val();
		  	var length = ccval.length;
		  	var re7digit=/^\d{7}$/
		  	var re3digit=/^\d{3}$/
		  					
			if (length!=12) {
				return false;
			}
			if(ccval.charAt(7)!='-')
			 {
			   return false;
			 }
			 if(ccval.charAt(11)!='-')
			 {
			   return false;
			 }
			/// alert(ccval.substring(0,7) +" " +ccval.substring(8,11));
			 if(ccval.substring(0,7).search(re7digit)==-1){
			  return false
			 }
			 if(ccval.substring(8,11).search(re3digit)==-1){
			  return false
			 }
			return true;
		 },
		 
		  "Please Enter Valid cost center number. i.e XXXXXXX-XXX-"
		 );		 
	
		$("#editCipeprojectForm").validate({
			rules : {
				'partner.id' : {
					//required : true
					partner_drop_down_required: true
				},
				acronym : {
					required : true
					
				},
				costCenterNumber : {
					required : true,
					validateCostCenterNumber:true
				},
				projectTitle : {
					required : true
				},
				// TO DO it was not visible as required field in frontend
				'donoraward.id' : {
					required : true
				},
				projectStartDate : {
					required : true,
					startDateValidation : true,
					startDateValidateDonorAward : true,
					startDateDonorEndDateValidateDonorAward : true
				},
				
				projectEndDate : {
					required : true,
					endDateValidation : true,
					endDateValidateDonorAward : true,
					endDateDonorStartDateValidateDonorAward : true
				},
				overrideAmount : {
					required : false,
					overrideValidation : true
				},
				overridePeriodStartDate : {
					required : false,
					overrideValidation : true,
					overridePeriodStartDateValidation : true
				},
				
				overridePeriodEndDate : {
					required : false,
					overrideValidation : true,
					overridePeriodEndDateValidation : true
				},
				'cipeprojecttype.id' : {
					required : true
				},
				'cipeprojectstatus.id' : {
					required : true
				},
				'region.id' : {
					required : true
				},
				'country.id' : {
					required : true
				},
				'seniorProgramOfficer.id' : {
					required : true
				},
				'programOfficer.id' : {
					required : true
				},
				'programAssistant.id' : {
					required : true
				},
				managementFunds : {
					required : true
				},
				fiscalYear : {
					required : true
				}
			}
		});
		$(document).ready(sortDropDownListByText);

		$("#projectStartDate").bind("change", getFiscalYear).trigger("change");
		$("#projectStartDate").bind("change", getStatus).trigger("change");
		$("#projectStartDate").bind("change", enableProjectEndDatefn).trigger("change");
		$("#creationDate").val($.format.date($("#creationDate").val(), "MM/dd/yyyy"));
           
		$("#updationDate").val($.format.date($("#updationDate").val(), "MM/dd/yyyy"));
      
      //  $('#costCenterNumber').bind('focus', function() {
			//alert(this.value);
		//	if(this.value=='XXXXXXX-XXX-'){
		//	  this.value="";
		//	  } else if($.trim(this.value)=='') {
		//	   this.value = "XXXXXXX-XXX-";
		//	  }
		// } ); 
        
         $('#costCenterNumber').bind('focusout', function() {
			//alert(this.value);
		//	 if($.trim(this.value)=='') {
		//	   this.value = "XXXXXXX-XXX-";
		//	  }
			  
			document.getElementById("projectID").value = this.value + "00";  
		 } ); 

		$('#cancelButton').click(function() {
				var ans = confirm('Are you sure you want to cancel editing this record without saving it?');
				if (ans) {
					location.href = '../secure/showDashboard.do';
				}
		});

		$('#editButton').click(function() {
			enabledControls();
			/*var inputs = $('#editCipeprojectForm :input');
			var selects = $('#editCipeprojectForm select');
			var checkboxes = $('#editCipeprojectForm checkbox');

			inputs.each(function() {
				$(this).removeAttr('readonly');
				$(this).removeAttr('disabled');
			});
			selects.each(function() {
				$(this).removeAttr('readonly');
				$(this).removeAttr('disabled');
			});
			checkboxes.each(function() {
				$(this).removeAttr('readonly');
				$(this).removeAttr('disabled');
			});
			$("#projectID").attr("readonly","readonly");*/
		});

		$("#countries").bind("change", function() {		  
			loadDataViaAjax("loadCountryUsers.do", {
				"countryId" : this.value
			}, function(result) {
				$("#programOfficer").get(0).value = result.programOfficer ? result.programOfficer : "";
				$("#programAssistant").get(0).value = result.programAssistant ? result.programAssistant : "";
			});
		});
		
		$('#programAssistant').bind("focusout",function(){		
		   $('#managementFundsLabel').click();
		});
			
		$('#managementFunds').numeric();

		$('#managementFunds').formatCurrency('#managementFundsLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
		showSubstitute(true, 'managementFundsLabel','managementFunds');

		$('#managementFunds').blur(function(){
			$('#managementFunds').formatCurrency('#managementFundsLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
			showSubstitute(true, 'managementFundsLabel','managementFunds');
		});

		$('#managementFundsLabel').click(function(){
			showSubstitute(false, 'managementFundsLabel','managementFunds');
		});

		$('#managementFundsLabel').focus(function() {
			$('#managementFundsLabel').css('display', 'none');
			$('#managementFunds').css('display', 'block');
			$('#managementFunds').focus();
		});
		
		$('#partnerGrantFunds').numeric();

		$('#partnerGrantFunds').formatCurrency('#partnerGrantFundsLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
		showSubstitute(true, 'partnerGrantFundsLabel','partnerGrantFunds');

		$('#partnerGrantFunds').blur(function(){
			$('#partnerGrantFunds').formatCurrency('#partnerGrantFundsLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
			showSubstitute(true, 'partnerGrantFundsLabel','partnerGrantFunds');
		});

		$('#partnerGrantFundsLabel').click(function(){
			showSubstitute(false, 'partnerGrantFundsLabel','partnerGrantFunds');
		});

		$('#partnerGrantFundsLabel').focus(function() {
			$('#partnerGrantFundsLabel').css('display', 'none');
			$('#partnerGrantFunds').css('display', 'block');
			$('#partnerGrantFunds').focus();
		});
		/*
		$('#managementFunds').blur(function() {
		    var strV = $('#managementFunds').val();
		   //  alert(strV.substring(0,strV.indexOf('.')) );
		   if(strV.indexOf('.')!=-1){
		    	strV = strV.substring(0,strV.indexOf('.')) ;
		    	$('#managementFunds').val( strV);
		    }
		    		   
			$('#managementFunds').formatCurrency('#managementFundsLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
		   	 // var errorMsg = 'Please do not enter any cents (0.' + cents + ')';
			 // $('#warnOnDecimalsEnteredNotification2').html(errorMsg);
			showSubstitute(true, 'managementFundsLabel','managementFunds');
		});
		$('#managementFundsLabel').click(function() {
			showSubstitute(false, 'managementFundsLabel','managementFunds');	
		});
		showSubstitute(true, 'managementFundsLabel','managementFunds');
		*/
		$('#overrideAmount').numeric();

		$('#overrideAmount').formatCurrency('#overrideAmountLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
		showSubstitute(true, 'overrideAmountLabel','overrideAmount');

		$('#overrideAmount').blur(function(){
			$('#overrideAmount').formatCurrency('#overrideAmountLabel',{colorize: true, negativeFormat: '-%s%n', roundToDecimalPlace: 2});
			showSubstitute(true, 'overrideAmountLabel','overrideAmount');
		});

		$('#overrideAmountLabel').click(function(){
			showSubstitute(false, 'overrideAmountLabel','overrideAmount');
		});

		$('#overrideAmountLabel').focus(function() {
			$('#overrideAmountLabel').css('display', 'none');
			$('#overrideAmount').css('display', 'block');
			$('#overrideAmount').focus();
		});

		disabledControls();
		
		

		$(".dhx_combo_input").rules("add", {
  			required:true
		});
		
		 $("#loginFormSubmit").bind("click",function(){
		
	      		var t= setTimeout(function(){
	      		$('.dhx_combo_input').click();
 	      		$('.input-full-width uneditable text_grey').click();
	      		},300);
	      		
	      		
	 		 	if($('.dhx_combo_input').eq(0).val() == ''){
	 				 $('.dhx_combo_box ').eq(0).css("border-color", "#B50007");
	 				 }
	 		
	       		 $('.dhx_combo_input').eq(0).blur(function() {
	     			 if($('.dhx_combo_input').eq(0).val()!= ''){
	     				 $('.dhx_combo_box ').eq(0).css("border-color", "#BDBCBD");
	     			 }
	     		 });
	       		 $('.dhx_combo_input').eq(0).keypress(function(event) {
	    			  if ( event.which == 8 || event.which == 9  || event.which == 40) {
	    				  var inputVal = $('.dhx_combo_input').eq(0).val().length;
	    			 		if(inputVal == 1){
	    					 $('.dhx_combo_box ').eq(0).css("border-color", "#B50007");
	    					 }else if(inputVal == 0){
	    						 $('.dhx_combo_box ').eq(0).css("border-color", "#B50007");
	    					}else{
	    						 $('.dhx_combo_box ').eq(0).css("border-color", "#BDBCBD");
	    					 }
	    				   }
	    			});
	      		 
		 	if($('.dhx_combo_input').eq(1).val() == ''){
				 $('.dhx_combo_box ').eq(1).css("border-color", "#B50007");
				 }
		
	  		 $('.dhx_combo_input').eq(1).blur(function() {
				 if($('.dhx_combo_input').eq(1).val()!= ''){
					 $('.dhx_combo_box ').eq(1).css("border-color", "#BDBCBD");
				 }
			 });
	  		 $('.dhx_combo_input').eq(1).keypress(function(event) {
				  if ( event.which == 8 || event.which == 9  || event.which == 40) {
					  var inputVal = $('.dhx_combo_input').eq(1).val().length;
				 		if(inputVal == 1){
						 $('.dhx_combo_box ').eq(1).css("border-color", "#B50007");
						 }else if(inputVal == 0){
							 $('.dhx_combo_box ').eq(1).css("border-color", "#B50007");
						}else{
							 $('.dhx_combo_box ').eq(1).css("border-color", "#BDBCBD");
						 }
					   }
				});
	   		
			 	if($('.dhx_combo_input').eq(2).val() == ''){
					 $('.dhx_combo_box ').eq(2).css("border-color", "#B50007");
					 }
			
	   		 $('.dhx_combo_input').eq(2).blur(function() {
	 			 if($('.dhx_combo_input').eq(2).val()!= ''){
	 				 $('.dhx_combo_box ').eq(2).css("border-color", "#BDBCBD");
	 			 }
	 		 });
	   		 $('.dhx_combo_input').eq(2).keypress(function(event) {
				  if ( event.which == 8 || event.which == 9  || event.which == 40) {
					  var inputVal = $('.dhx_combo_input').eq(2).val().length;
				 		if(inputVal == 1){
						 $('.dhx_combo_box ').eq(2).css("border-color", "#B50007");
						 }else if(inputVal == 0){
							 $('.dhx_combo_box ').eq(2).css("border-color", "#B50007");
						}else{
							 $('.dhx_combo_box ').eq(2).css("border-color", "#BDBCBD");
						 }
					   }
				});
	   		 

			 	if($('.dhx_combo_input').eq(3).val() == ''){
					 $('.dhx_combo_box ').eq(3).css("border-color", "#B50007");
					 }
			
	   		 $('.dhx_combo_input').eq(3).blur(function() {
	 			 if($('.dhx_combo_input').eq(3).val()!= ''){
	 				 $('.dhx_combo_box ').eq(3).css("border-color", "#BDBCBD");
	 			 }
	 		 });
	   		 $('.dhx_combo_input').eq(3).keypress(function(event) {
				  if ( event.which == 8 || event.which == 9  || event.which == 40) {
					  var inputVal = $('.dhx_combo_input').eq(3).val().length;
				 		if(inputVal == 1){
						 $('.dhx_combo_box ').eq(3).css("border-color", "#B50007");
						 }else if(inputVal == 0){
							 $('.dhx_combo_box ').eq(3).css("border-color", "#B50007");
						}else{
							 $('.dhx_combo_box ').eq(3).css("border-color", "#BDBCBD");
						 }
					   }
				});
	
	  

			 	if($('.dhx_combo_input').eq(4).val() == ''){
					 $('.dhx_combo_box ').eq(4).css("border-color", "#B50007");
					 }
			
	   		 $('.dhx_combo_input').eq(4).blur(function() {
	 			 if($('.dhx_combo_input').eq(4).val()!= ''){
	 				 $('.dhx_combo_box ').eq(4).css("border-color", "#BDBCBD");
	 			 }
	 		 });
	   		 $('.dhx_combo_input').eq(4).keypress(function(event) {
				  if ( event.which == 8 || event.which == 9  || event.which == 40) {
					  var inputVal = $('.dhx_combo_input').eq(4).val().length;
				 		if(inputVal == 1){
						 $('.dhx_combo_box ').eq(4).css("border-color", "#B50007");
						 }else if(inputVal == 0){
							 $('.dhx_combo_box ').eq(4).css("border-color", "#B50007");
						}else{
							 $('.dhx_combo_box ').eq(4).css("border-color", "#BDBCBD");
						 }
					   }
				}); 

			 	if($('.dhx_combo_input').eq(5).val() == ''){
					 $('.dhx_combo_box ').eq(5).css("border-color", "#B50007");
					 }
			 
			
	   		 $('.dhx_combo_input').eq(5).blur(function() {
	 			 if($('.dhx_combo_input').eq(5).val()!= ''){
	 				 $('.dhx_combo_box ').eq(5).css("border-color", "#BDBCBD");
	 			 }
	 		 });
	   		 $('.dhx_combo_input').eq(5).keypress(function(event) {
				  if ( event.which == 8 || event.which == 9  || event.which == 40) {
					  var inputVal = $('.dhx_combo_input').eq(5).val().length;
				 		if(inputVal == 1){
						 $('.dhx_combo_box ').eq(5).css("border-color", "#B50007");
						 }else if(inputVal == 0){
							 $('.dhx_combo_box ').eq(5).css("border-color", "#B50007");
						}else{
							 $('.dhx_combo_box ').eq(5).css("border-color", "#BDBCBD");
						 }
					   }
				});
	   		if($('.dhx_combo_input').eq(6).val() == ''){
				 $('.dhx_combo_box ').eq(6).css("border-color", "#B50007");
				 }
		
  		 $('.dhx_combo_input').eq(6).blur(function() {
			 if($('.dhx_combo_input').eq(6).val()!= ''){
				 $('.dhx_combo_box ').eq(6).css("border-color", "#BDBCBD");
			 }
		 });
  		 $('.dhx_combo_input').eq(6).keypress(function(event) {
			  if ( event.which == 8 || event.which == 9  || event.which == 40) {
				  var inputVal = $('.dhx_combo_input').eq(6).val().length;
			 		if(inputVal == 1){
					 $('.dhx_combo_box ').eq(6).css("border-color", "#B50007");
					 }else if(inputVal == 0){
						 $('.dhx_combo_box ').eq(6).css("border-color", "#B50007");
					}else{
						 $('.dhx_combo_box ').eq(6).css("border-color", "#BDBCBD");
					 }
				   }
			});if($('.dhx_combo_input').eq(7).val() == ''){
				 $('.dhx_combo_box ').eq(7).css("border-color", "#B50007");
			 }
	
		 $('.dhx_combo_input').eq(7).blur(function() {
		 if($('.dhx_combo_input').eq(7).val()!= ''){
			 $('.dhx_combo_box ').eq(7).css("border-color", "#BDBCBD");
		 }
	 });
		 $('.dhx_combo_input').eq(7).keypress(function(event) {
		  if ( event.which == 8 || event.which == 9  || event.which == 40) {
			  var inputVal = $('.dhx_combo_input').eq(7).val().length;
		 		if(inputVal == 1){
				 $('.dhx_combo_box ').eq(7).css("border-color", "#B50007");
				 }else if(inputVal == 0){
					 $('.dhx_combo_box ').eq(7).css("border-color", "#B50007");
				}else{
					 $('.dhx_combo_box ').eq(7).css("border-color", "#BDBCBD");
				 }
			   }
		});
		 });
		 
		onChangeDonorAwardId();
	});

	function enabledControls() {
		<c:if test="${cipeproject.id !=null and cipeproject.id gt 0}">
// 			$("form :input").removeAttr("disabled","disabled");
            $("form :input").removeAttr("readonly","readonly");   
    		var selects = $('#editCipeprojectForm select');
        	selects.each(function(){
        		$(this).removeAttr("disabled");
        		
        	});
        	var pickerOpts = {
        			onClose : function() {
        				this.focus();
        			}
        		};
        	$("#projectStartDate").datepicker(pickerOpts);        		
        	$("#projectEndDate").datepicker(pickerOpts);        
        	$("#overridePeriodStartDate").datepicker(pickerOpts);        		
        	$("#overridePeriodEndDate").datepicker(pickerOpts);
			$("#donorName").attr("readonly","readonly");
			$("#donorStartDate").attr("readonly","readonly");
			$("#donorEndDate").attr("readonly","readonly");
			$("#projectID").attr("readonly","readonly");
			$("#createdBy").attr("disabled","disabled");
			$("#creationDate").attr("readonly","readonly");
			$("#updatedBy").attr("disabled","disabled");
			$("#updationDate").attr("readonly","readonly");
			$("#loginFormSubmit").removeAttr("disabled","disabled");
			$("#cancelButton").removeAttr("disabled","disabled");
			$("#editButton").attr("disabled","disabled");
			

			z1.readonly(false,true);			
			z2.readonly(false,true);
			z3.readonly(false,true);
			z4.readonly(false,true);
			z5.readonly(false,true);
			z7.readonly(false,true);
			z8.readonly(false,true);
			z9.readonly(false,true);
			
		</c:if>
	}

	function disabledControls() {
		<c:if test="${cipeproject.id !=null and cipeproject.id gt 0}">
// 			$("form :input").attr("disabled","disabled");
      		$("form :input").attr("readonly","readonly");
      		var selects = $('#editCipeprojectForm select');
        	selects.each(function(){ 
        	
//         		$(this).attr("onfocus","this.initialSelect = this.selectedIndex;");
//         		$(this).attr("onchange","this.selectedIndex = this.initialSelect;");  
                $(this).attr("disabled","true");
        	});
        	$("#projectStartDate").datepicker("disable");     		
        	$("#projectEndDate").datepicker("disable");

        	$("#overridePeriodStartDate").datepicker("disable");     		
        	$("#overridePeriodEndDate").datepicker("disable");
        	

			$("input[type^='button']").removeAttr("disabled","disabled");
			$("input[type^='submit']").removeAttr("disabled","disabled");
			$("#loginFormSubmit").attr("disabled","disabled");
			$("#cancelButton").attr("disabled","disabled");
			$("#editButton").removeAttr("disabled","disabled");		
			
			z1.readonly(true,false);
// 			z1.clearAll();
			z2.readonly(true,false);
// 			z2.clearAll();
			z3.readonly(true,false);
// 			z3.clearAll();
			z4.readonly(true,false);
// 			z4.clearAll();
			z5.readonly(true,false);
// 			z5.clearAll();
			z7.readonly(true,false);
// 			z7.clearAll();
			z8.readonly(true,false);
// 			z8.clearAll();
			z9.readonly(true,false);
// 			z9.clearAll();
		</c:if>
	}
	
	function showSubstitute(show, subId, tobeSubId) {
		if(show) {
			$('#' + subId).css('display', 'block');
			$('#' + tobeSubId).css('display', 'none');
		} else {
			$('#' + subId).css('display', 'none');
			$('#' + tobeSubId).css('display', 'block');
			$('#' + tobeSubId).focus();
		}
	}
    
// 	function parseCountriesJson(data) {
// 		var html = "<option value=''>Select</option>";
// 		var directorId = "";
// 		if (data) {
// 			for (p in data) {
// 				if (p != 'director') {
// 					html += "<option value='" + p + "'>" + data[p] + "</option>";
// 				} else {
// 					directorId = data[p];
// 				}
// 			}
// 		}
// 		$("#countries option").remove();
// 		$("#countries").append(html).trigger("change");
// 		$("#seniorProgramOfficer").get(0).value = directorId;
// 		sortDropDownListByText();
// 	}
	function parseCountriesJson(data) {
		z8.clearAll();
		var html = "<option value=''>Select</option>";
		z8.addOption('','Select',274);
		var directorId = "";
		if (data) {
			for (p in data) {
				if(p != 'director') { 
					html = "<option value='" + p + "'>" + data[p] + "</option>";
					z8.addOption(p,data[p],274);

				} else {
					directorId = data[p];
				}
			}
		}
		z2.setComboValue(directorId);
	
		
		sortDropDownListByText();
	}

	function parseDonorAwardJson(data) {
		var found = false;
		var donorAwardId = z5.getSelectedValue();
		z5.clearAll();
		if (data) {
			z5.setComboValue("");
			z5.setComboText("",274);
			for (p in data) {
					z5.addOption(data[p],p,274);
					if (!found && data[p] == donorAwardId) {
						found = true;
					}
				}
		}
		if (found) z5.setComboValue(donorAwardId);
		 
		onChangeDonorAwardId();
		
		sortDropDownListByText();
	}
	
	
// 	$(function() {
		
// 		$("#projectStartDate").datepicker(pickerOpts);
// 	});                                                
// 	$(function() {
		
// 		$("#projectEndDate").datepicker(pickerOpts);
// 	});	
	
// 	$(function() {
		
// 		$("#overridePeriodStartDate").datepicker(pickerOpts);
// 	});                                                
// 	$(function() {
		
// 		$("#overridePeriodEndDate").datepicker(pickerOpts);
// 	});
	$('#add-partner').click(function() {
		loadDiv('content', 'showAddPartner.do?fromProject=true');
	});

	$('#add-partnergrant').click(function() {
		loadDiv('content', 'showAddPartnergrantWithProject.do?cipeprojectId=' + $(this).attr('cipeprojectId'));
	});
	
	$('#edit-donoraward').click(function() {
		var idVal = document.getElementsByName("donoraward.id")[0].value;
		if (idVal != 0) {
			loadDiv('content', 'showEditDonoraward.do?id=' + idVal);
		}
	});
		$('.close-button').click(function() {
			if (confirm('Are you sure you want to close the form?')) {
				window.location = '../secure/showDashboard.do';
			}
		});
	function getFiscalYear() {	
		var str1 = document.getElementById("projectStartDate").value;
		var dateParts = str1.split("/");
		var mon1 =  parseInt(dateParts[0]);
		var dt1 =  parseInt(dateParts[1]);
		var yr1 =  parseInt(dateParts[2]);
		
		if(yr1 < 100){
			yr1 += 2000;
		}
		var dt2 = 1;
		var mon2 = 10;
		var date1 = new Date(yr1, mon1, dt1);
		var date2 = new Date(yr1, mon2, dt2);
		if (isNaN(yr1)) {
			//do nothing
		} else {

			if (date1 >= date2) {
				document.getElementById("fiscalYear").value = yr1 + 1;
			} else {
				document.getElementById("fiscalYear").value = parseInt(yr1);
			}
		}
	}	
	function getStatus() {		
		var str1 = document.getElementById("projectStartDate").value;
		var mon1 = parseInt(str1.substring(0, 2), 10) - 1;//Number of month (0-11)
		var dt1 = parseInt(str1.substring(3, 5), 10);
		var yr1 = parseInt(str1.substring(6, 10), 10);
		var today = new Date();
		var date1 = new Date(yr1, mon1, dt1);
		if (date1 > today) {
		//	$("#status").val("5");//set status to Pending
			z9.setComboValue("5");
		} else {
		//	$("#status").val("1");//set status to Active
			z9.setComboValue("1");
		}
	}
	function sortDropDownListByText() {
		// Loop for each select element on the page.

		$("select").each(function() {

			// Keep track of the selected option.
			var selectedValue = $(this).val();
			// Sort all the options by text.
			$(this).html($("option", $(this)).sort(function(a, b) {

				return a.text == b.text ? 0 : ((a.text < b.text) || (a.value == '')) ? -1 : 1;
				// return a.text == $(selectId + 'option:first').text ? -1 : a.text < b.text ? -1 : 1;
			}));

			// Select one option.
			$(this).val(selectedValue);
		});
	}

	function enableProjectEndDatefn() {

		if ($("#projectStartDate").val() == "") {
			//do nothing
		} else {

			$("#projectEndDate").removeAttr('readonly');
			$("#projectEndDate").removeAttr('disabled');
		}
	}
	
	$("#projectEndDate").change(function() {
		var date_ini = new Date($('#projectStartDate').val()).getTime();
		var date_end = new Date($('#projectEndDate').val()).getTime();
		if (isNaN(date_ini)) {
			//if required we will add code
		} else if (isNaN(date_end)) {
			//if required we will add code
		} else if (date_ini > date_end) {

			alert("The Project End date must be after Project Start Date");

		}

	});

	 var z1 = dhtmlXComboFromSelect("cipeprojecttype.id",274);
	  z1.enableFilteringMode(true);
	  z1.attachEvent("onChange",function(){
		  onChangeCipeprojecttypeId();
			
		});
	  var z2 = dhtmlXComboFromSelect("seniorProgramOfficer",274);
	  z2.enableFilteringMode(true);
	  var z3 = dhtmlXComboFromSelect("programOfficer",274);
	  z3.enableFilteringMode(true);
	  var z4 = dhtmlXComboFromSelect("programAssistant",274);
	  z4.enableFilteringMode(true);
	  var z5 = dhtmlXComboFromSelect("donorawardId",274);
	  z5.enableFilteringMode(true);
	  z5.attachEvent("onChange",function(){
		  onChangeDonorAwardId();
			
		});
	  
	  function onChangeCipeprojecttypeId()
	  {
			var projecttype = z1.getSelectedText();
			var donorAwardId = z5.getSelectedValue();
			if(projecttype=="Select" || projecttype=="" || projecttype==null) {
				loadDataViaAjax("getActiveDonoraward.do", donorAwardId != "" ? {
					"donorawardId" : donorAwardId
				} : {}, parseDonorAwardJson);
			}else if(projecttype=="Balance Sheet"/*value=35*/){				
				loadDataViaAjax("getActiveDonorawardOnlyBalanceSheet.do", donorAwardId != "" ? {
					"donorawardId" : donorAwardId
				} : {}, parseDonorAwardJson);				
			} else {
				loadDataViaAjax("getActiveDonorawardNoBalanceSheet.do", donorAwardId != "" ? {
					"donorawardId" : donorAwardId
				} : {}, parseDonorAwardJson);
			}

			changePartnerDropDownRequired();
	  }

	  function changePartnerDropDownRequired() {
			var projecttype = z1.getSelectedText();

			var classNameReq = 'input-full-width-req text_blue';
			var classNameNotReq = 'input-full-width text_white';
			if(projecttype=="Management"/*value=30*/ || projecttype=="Partner"/*value=32*/) {
				$('#partner').removeClass(classNameNotReq).addClass(classNameReq);
			} else {
				$('#partner').removeClass(classNameReq).addClass(classNameNotReq);
			}
	  }

	  changePartnerDropDownRequired();
	  
	  function onChangeDonorAwardId()
	  {
			if ($('input[name="donoraward.id"]').val() != '') {
				loadDataViaAjax("getDonorAwardBean.do", {
					"donorawardId" : $('input[name="donoraward.id"]').val()
				}, function(bean) {
					$('#donorName').val(bean.donorName);
					$('#donorStartDate').val(bean.formattedStartDate);
					$('#donorEndDate').val(bean.formattedEndDate);
					$('#fiscalYear').val(bean.donorFiscalYear);
				});
			} else {
				
				$('#donorName').val('');
				$('#donorStartDate').val('');
				$('#donorEndDate').val('');
				$('#fiscalYear').val('');
			}
		  
	  }
	  
	
// 	  var z6 = dhtmlXComboFromSelect("masterProject",274);
// 	  z6.enableFilteringMode(true);
	  var z7 = dhtmlXComboFromSelect("regions",274);
	  z7.enableFilteringMode(true);
      z7.attachEvent("onChange",function(){
	 		loadDataViaAjax("loadCountries.do", {
	 			"regionId" : z7.getSelectedValue()
	 		}, parseCountriesJson);
			
	 	});
      var reInteger = /^\d+$/;

      function isInteger (s)
      {    
          return reInteger.test(s);
      }

		
	  var z8 = dhtmlXComboFromSelect("countries",274);
	  z8.enableFilteringMode(true);
	  z8.attachEvent("onChange",function(){
			  if( isInteger(z8.getSelectedValue()))
			  {
				loadDataViaAjax("loadCountryUsers.do", {
					"countryId" : z8.getSelectedValue()
				}, function(result) {
					z3.setComboValue(result.programOfficer ? result.programOfficer : "");
					z4.setComboValue(result.programAssistant ? result.programAssistant : "");
				});
			 }
		});
	  var z9 = dhtmlXComboFromSelect("status",274);
	  z9.enableFilteringMode(true);
	  
	 
</script>
<div id="editCipeprojectDiv">
	<form:form name="editCipeprojectForm" id="editCipeprojectForm"
		action="saveCipeproject.do" method="post" modelAttribute="cipeproject">
		<form:hidden path="id" />
		<div class="main_form">
			<div class="form_head">
				<div class="floatL" style="padding-top: 5px;">
					<c:choose>
						<c:when test="${cipeproject.id !=null and cipeproject.id gt 0}">
							<a href="#" id="add-partnergrant" class="blue_btn"
								cipeprojectId="${cipeproject.id}" tabindex="-1"><spring:message
									code="editCipeproject.link.addParntergrant" />
							</a>
						</c:when>
						<c:otherwise>
						</c:otherwise>
					</c:choose>
				</div>
				<a href="#" class="close-button gray_btn floatR" tabindex="-1">Close
					Form</a><br class="clear" />
			</div>
			<div class="form_cont">
				<table cellspacing="5" width="100%">
					
					<tr class="row">
						<td class="input-field" colspan="5" style="text-align: center; "><%@ include
								file="/common/messages.jsp"%></td>
					</tr>
					<tr>
						<td id="space" class="label">&nbsp;</td>
						<td>&nbsp;</td>
						<td width="50">&nbsp;</td>
						<td class="label">&nbsp;</td>
						<td></td>
					</tr>
					<tr class="row">
						<td class="label" style="padding-left:20px;"><spring:message code="editCipeproject.label.type" />
						</td>
						<td class="input-field"><form:select
								path="cipeprojecttype.id"
								cssClass="input-full-width-req text_blue" tabindex="1">
								<form:option value="" label="" />
								<form:options items="${cipeprojecttypeList}" itemValue="id"
									itemLabel="displayName" />
							</form:select> <form:errors path="cipeprojecttype.id" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label" style="padding-left:120px;"><spring:message
								code="editCipeproject.label.seniorProgramOfficer" />
						</td>
						<td class="input-field"><form:select
								id="seniorProgramOfficer" path="seniorProgramOfficer.id"
								cssClass="input-full-width-req text_blue" tabindex="17">
								<form:option value="" label="" />
								<form:options items="${seniorProgramOfficerList}" itemValue="id"
									itemLabel="fullName" />
							</form:select> 
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message
								code="editCipeproject.label.costCenter" />
						</td>
						<td class="input-field"><form:input path="costCenterNumber"
								id="costCenterNumber" maxlength="50"
								cssClass="input-full-width-req text_blue" tabindex="2" /> <form:errors
								path="costCenterNumber" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message
								code="editCipeproject.label.programOfficer" />
						</td>
						<td class="input-field"><form:select id="programOfficer"
								path="programOfficer.id"
								cssClass="input-full-width-req text_blue" tabindex="18">
								<form:option value="" label="" />
								<form:options items="${programOfficerList}" itemValue="id"
									itemLabel="fullName" />
							</form:select> 
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message
								code="editCipeproject.label.projectID" />
						</td>
						<td class="input-field"><c:choose>
								<c:when test="${cipeproject.id !=null and cipeproject.id gt 0 or not empty cipeproject.projectID}">
									<form:input path="projectID" maxlength="50" readonly="true"
										cssClass="input-full-width text_grey" tabindex="3" />
								</c:when>
								<c:otherwise>
									<form:input path="projectID" maxlength="50" value="-00" readonly="true"
										cssClass="input-full-width text_grey" tabindex="3" />
								</c:otherwise>
							</c:choose> <form:errors path="projectID" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message
								code="editCipeproject.label.programAssistant" />
						</td>
						<td class="input-field"><form:select id="programAssistant"
								path="programAssistant.id"
								cssClass="input-full-width-req text_blue" tabindex="19">
								<form:option value="" label="" />
								<form:options items="${programAssistantList}" itemValue="id"
									itemLabel="fullName" />
							</form:select> 
						</td>
					</tr>
					<tr class="row">
						<td class="label2"><spring:message code="editCipeproject.label.partner" /></td>
						<td class="input-field" nowrap="nowrap"><form:select
								id="partner" path="partner.id"
								cssClass="input-full-width-req text_blue" tabindex="4">
								<form:option value="" label="Select" />
								<form:options items="${partnerList}" itemValue="id" itemLabel="partnerName" />
							</form:select> <form:errors path="partner.id"
								cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<%-- <td><input type="button" class="blue_btn"
 							id="add-partner" value="<spring:message code="link.add" />"
							cipeprojectId="${cipeproject.id}"tabindex="-1" /> <form:errors path="partner.id"
								cssClass="error" />
						</td> --%>
						<td class="label"><spring:message
								code="editCipeproject.label.managementFunds" />
						</td>
						<td class="input-field"><form:input
								path="managementFunds" cssClass="input-full-width-req text_blue"
								tabindex="20" /> <input type="text" value="&nbsp;"
							readonly="readonly" id="managementFundsLabel"
							class="uneditable input-sub input-full-width-req text_blue"
							tabindex="20" /> <form:errors path="managementFunds"
								cssClass="error" /></td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message
								code="editCipeproject.label.donorAwardID" />
						</td>
						<td class="input-field" nowrap="nowrap"><form:select
								id="donorawardId" path="donoraward.id"
								cssClass="input-full-width-req text_blue" tabindex="5">
								<form:option value="" label="" />
								<form:options items="${donorawardList}" itemValue="id"
									itemLabel="fullDonorawardNumber" />
							</form:select></td>
						<td><input type="button" class="blue_btn"
							id="edit-donoraward" value="<spring:message code="link.view" />"
							tabindex="-1" /> <form:errors path="donoraward.id"
								cssClass="error" />
						</td>
						<td class="label"><spring:message
								code="editCipeproject.label.partnerGrantFund" />
						</td>
						<td class="input-field">
						     <form:input path="partnerGrantFunds" cssClass="input-full-width-req text_blue" tabindex="21" />
							 <input type="text" value="&nbsp;" readonly="readonly" id="partnerGrantFundsLabel"
							class="uneditable input-sub input-full-width-req text_blue"
							tabindex="21" />
							 <form:errors path="partnerGrantFunds" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message
								code="editCipeproject.label.donorName" />
						</td>
						<td class="input-field"><form:input path="" readonly="true"
								cssClass="input-full-width text_grey" id="donorName"
								tabindex="6" /> <form:errors path="" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message
								code="editCipeproject.label.rollup" />
						</td>
						<td class="input-field"><form:select path="masterProject.id"
								cssClass="text_white" tabindex="22">
								<form:option value="" label="" />
								<form:options items="${cipeprojectrollupList}" itemValue="id"
									itemLabel="rollUp" />
							</form:select> <form:errors path="masterProject.id" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message
								code="editCipeproject.label.donorStartDate" />
						</td>
						<td class="input-field"><form:input path="" readonly="true"
								cssClass="input-full-width text_grey" id="donorStartDate"
								tabindex="7" /> <form:errors path="" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message
								code="editCipeproject.label.fiscalYear" />
						</td>
						<td class="input-field"><form:input path="fiscalYear" id="fiscalYear"
								cssClass="input-full-width text_blue" tabindex="23" /> <form:errors
								path="fiscalYear" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message
								code="editCipeproject.label.donorEndDate" />
						</td>
						<td class="input-field"><form:input path="" readonly="true"
								cssClass="input-full-width text_grey" id="donorEndDate"
								tabindex="8" /> <form:errors path="" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message
								code="editCipeproject.label.memo" />
						</td>
						<td class="input-field"><form:input path="memo" maxlength="5000"
								cssClass="input-full-width text_white" tabindex="24" /> <form:errors
								path="memo" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message
								code="editCipeproject.label.startDate" />
						</td>
						<td class="input-field"><form:input path="projectStartDate"
								cssClass="input-full-width-req text_blue" tabindex="9" /> <form:errors
								path="projectStartDate" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message
								code="editCipeproject.label.fileLocation" />
						</td>
						<td class="input-field"><form:input path="fileLocation" maxlength="512"
								cssClass="input-full-width text_white" tabindex="25" /> <form:errors
								path="fileLocation" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message
								code="editCipeproject.label.endDate" />
						</td>
						<td class="input-field"><form:input path="projectEndDate"
								cssClass="input-full-width-req text_blue" tabindex="10" /> <form:errors
								path="projectEndDate" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message
								code="editCipeproject.label.blockTimeSheet" />
						</td>
						<td class="input-field"><form:checkbox path="blockTimeSheet"
								cssClass="input-full-width" value="true" tabindex="26" /> <form:errors
								path="blockTimeSheet" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message
								code="editCipeproject.label.acronym" />
						</td>
						<td class="input-field"><form:input path="acronym" maxlength="50"
								cssClass="input-full-width-req text_blue" tabindex="11" /> <form:errors
								path="acronym" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message
								code="editCipeproject.label.override" />
						</td>
						<td class="input-field"><form:checkbox path="override"
								cssClass="input-full-width" value="true" tabindex="27" /> <form:errors
								path="override" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message
								code="editCipeproject.label.projectTitle" />
						</td>
						<td class="input-field"><form:input path="projectTitle" maxlength="100"
								cssClass="input-full-width-req text_blue" tabindex="12" />
							<form:errors path="projectTitle" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message
								code="editCipeproject.label.overrideAmount" />
						</td>
						<td class="input-field"><form:input
								path="overrideAmount" cssClass="input-full-width-req text_blue"
								tabindex="28" /> <input type="text" value="&nbsp;"
							readonly="readonly" id="overrideAmountLabel"
							class="uneditable input-sub input-full-width-req text_blue"
							tabindex="28" /> <form:errors path="overrideAmount"
								cssClass="error" /></td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message
								code="editCipeproject.label.region" />
						</td>
						<td class="input-field"><form:select path="region.id"
								cssClass="input-full-width-req text_blue" id="regions"
								tabindex="13">
								<form:option value="" label="" />
								<form:options items="${regionList}" itemValue="id"
									itemLabel="displayName" />
							</form:select> 
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message
								code="editCipeproject.label.overridePeriodStartDate" />
						</td>
						<td class="input-field"><form:input path="overridePeriodStartDate"
								cssClass="input-full-width-req text_blue" tabindex="29" /> <form:errors
								path="overridePeriodStartDate" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message
								code="editCipeproject.label.country" />
						</td>
						<td class="input-field"><form:select path="country.id"
								id="countries" cssClass="input-full-width-req text_blue"
								tabindex="14">
								<form:option value="" label="" />
								<form:options items="${countryList}" itemValue="id"
									itemLabel="displayName" />
							</form:select> 
<%-- 							<form:errors path="country.id" cssClass="error" /> --%>
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message
								code="editCipeproject.label.overridePeriodEndDate" />
						</td>
						<td class="input-field"><form:input path="overridePeriodEndDate"
								cssClass="input-full-width-req text_blue" tabindex="30" /> <form:errors
								path="overridePeriodEndDate" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="label"><spring:message
								code="editCipeproject.label.status" />
						</td>
						<td class="input-field"><form:select
								path="cipeprojectstatus.id"
								cssClass="input-full-width-req text_blue" id="status"
								tabindex="15">
								<c:choose>
									<c:when test="${cipeproject.id !=null and cipeproject.id gt 0}">
										<form:option value="" label="" />
										<form:options items="${cipeprojectstatusList}" itemValue="id"
											itemLabel="displayName" />
									</c:when>
									<c:otherwise>
										<form:option value="1" label="Active" />
										<form:option value="5" label="Pending" />
									</c:otherwise>
								</c:choose>
							</form:select> <form:errors path="cipeprojecttype.id" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.createdBy" />
						</td>
						<td class="input-field"><form:input readonly="true"
								path="createdBy.fullName" cssClass="input-full-width text_grey"
								tabindex="31" /> <form:errors path="createdBy" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
					   <td class="label"><spring:message
								code="editCipeproject.label.nedIdentifier" />
						</td>
						<td class="input-field"><form:input path="nedIdentifier" maxlength="50"
								cssClass="input-full-width text_white" tabindex="16" /> <form:errors
								path="nedIdentifier" cssClass="error" />
						</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.creationDate" />
						</td>
						<td class="input-field"><form:input readonly="true"
								path="creationDate" cssClass="input-full-width text_grey"
								tabindex="32" /> <form:errors path="creationDate"
								cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td width="50">&nbsp;</td>
						<td width="50">&nbsp;</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.updatedBy" />
						</td>
						<td class="input-field"><form:input readonly="true"
								path="updatedBy.fullName"
								cssClass="input-full-width text_grey" tabindex="33" /> <form:errors
								path="updatedBy" cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td width="50">&nbsp;</td>
						<td width="50">&nbsp;</td>
						<td width="50">&nbsp;</td>
						<td class="label"><spring:message code="label.updationDate" />
						</td>
						<td class="input-field"><form:input readonly="true"
								path="updationDate" cssClass="input-full-width text_grey"
								tabindex="34" /> <form:errors path="updationDate"
								cssClass="error" />
						</td>
					</tr>
					<tr class="row">
						<td class="input-field" colspan="5" style="text-align: center;"><c:choose>
								<c:when test="${cipeproject.id !=null and cipeproject.id gt 0}">
									<input id="editButton" class="blue_btn" type="button"
										value="Edit" tabindex="35" />
									<input id="cancelButton" class="blue_btn" type="reset"
										value="<spring:message code='button.cancel' />"
										tabindex="36" />
									<sj:submit id="loginFormSubmit" cssClass="blue_btn"
										target="z1.readonly(false,true);" key="editCipeproject.button.save"
										validate="true" tabindex="37" />
								</c:when>
								<c:otherwise>
									<input id="cancelButton" class="blue_btn" type="reset"
										value="<spring:message code='button.cancel' />"
										tabindex="35" />
									<sj:submit id="loginFormSubmit" cssClass="blue_btn"
										target="editCipeprojectDiv" key="editCipeproject.button.save"
										validate="true" tabindex="36" />
								</c:otherwise>
							</c:choose>
						</td>
					</tr>
				</table>
				<br class="clear" />
				<c:if
					test="${isGrantUser || isStaffUser || isKmUser || isSrManagementUser || isAdminUser }">
					<table class="tablesorter">
						<thead>
							<tr>
								<th>ID</th>
								<th>Modification Type</th>
								<th>Modified From</th>
								<th>Modified To</th>
								<th>Modified Date</th>
								<th>Modified By</th>
								<th>File Location of Modified Document</th>
							</tr>
						</thead>
						<tbody>
							<c:choose>
								<c:when
									test="${fn:length(cipeproject.cipeprojectmodifications) > 0}">
									<c:forEach items="${cipeproject.cipeprojectmodifications}"
										var="modification">
										<tr>
											<td>${modification.id}</td>
											<td>${modification.modificationType.modificationTypeDesc}</td>
											<td>${modification.modifiedFrom}</td>
											<td>${modification.modifiedTo}</td>
											<td>${modification.formattedModifiedDate}</td>
											<td>${modification.modifiedBy.fullName}</td>
											<td>${modification.attachment}</td>
										</tr>
									</c:forEach>
								</c:when>
								<c:otherwise>
									<tr>
										<td colspan="7" style="padding-left: 10px;">No
											modifications found.</td>
									</tr>
								</c:otherwise>
							</c:choose>
						</tbody>
					</table>
				</c:if>
			</div>
		</div>
	</form:form>
</div>
